﻿<%@ Page Title="" Language="C#" MasterPageFile="../master/faa.master" AutoEventWireup="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">  
    #fm{ margin:0; padding:10px 30px; }  
    .ftitle{ font-size:14px; font-weight:bold; padding:5px 0; margin-bottom:10px; border-bottom:1px solid #ccc; }  
    .fitem{ margin-bottom:5px; }  
    .fitem label{ display:inline-block; width:100px; }  
    .fitem input,textarea{ width:280px; }
</style>  
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
    <div class="clear  wide" id="bodyPadding">
        <!--左侧导航栏-->
        <div id="vNav">
            <ul class="Sle S2">
                <li>
                    <h4>基元信息</h4>
                    <ul>
                        <li><a class="here" href="jiyuanXM.aspx">浏览基元项目</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="Sle S2">
                <li>
                    <h4>管理基元库</h4>
                    <ul>
                        <li><a href="jiyuanXMSH.aspx">审核基元项目</a></li>
                        <li><a href="jiyuanNRSH.aspx">审核基元内容</a></li>
                    </ul>
                </li>
            </ul>
        </div>
        
        <!--右上快速链接栏-->
        <div class="clear" id="breadcrumbs">
            <p>
                <a href="#">基元系统</a> <span>»</span> <a href="#">基元项目</a> <span>»</span> 添加基元项目
            </p>
        </div>
        
        <!--右下主体栏-->
        <div class="whiteSheet">
            <div class="content" id="content_01">
	            <h1 class="pageTitle">基元项目查看</h1>
	            <div class="demo-info">
		            <div class="demo-tip icon-tip"></div>
		            <div>查看基元项目，选择相应的项目查看对应的基元</div>
	            </div>
	            
	            <div id="tb" style="padding:5px;height:auto">  
                    <div style="margin-bottom:5px">
                        <table cellpadding="0" cellspacing="0" style="width: 100%">
                            <tr>
                                <td>
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newItem()">新增</a>  
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editItem()">编辑</a>  
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="delItem()">删除</a>  
                                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="viewItem()">查看检查内容</a>
                                </td>
                                <td style="text-align: right">
                                    <label>按专业筛选：</label>
                                    <input name="jyxmProf" class="easyui-combobox" editable="false" 
                                    data-options="url:'/template_faa/handler/combobox.ashx?name=jcyZY', 
                                        valueField:'jcyzyId', textField:'jcyzyName', panelHeight:'auto',
                                        onSelect: function(rec){
                                        $('#dg').datagrid({url:'/template_faa/handler/grid.ashx',    
                                        queryParams:{zhuanye:rec.jcyzyId, view:'jiyuanXM' }
                                        });
                                        $('#dg').datagrid('reloadFooter');
                                    }" />  
                                </td>
                            </tr>
                        </table>
                    </div>  
                </div>  
            	
                <table id="dg" class="easyui-datagrid" style="width:700px;height:400px"  
                        url="/template_faa/handler/grid.ashx?view=jiyuanXM" 
                        title="基元项目列表" singleSelect="true" toolbar="#tb"
                        rownumbers="true" pagination="true" pageSize="10" singleSelect="true">  
                    <thead>  
                        <tr>  
                            <th field="jyxmId" width="80" hidden="true">基元项目Id</th>  
                            <th field="jyxmName" width="325">基元项目名称</th>  
                            <th field="jyxmCreateOwner" width="100" align="center">创建人</th>  
                            <th field="jyxmCreateDate" width="100" align="center">创建时间</th>  
                            <th field="jyxmProf" width="135" hidden="true">对应专业</th>
                            <th field="jyxmProfChar" width="135" align="center">对应专业</th>    
                        </tr>  
                    </thead>  
                </table>
                
                <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"  
                    closed="true" buttons="#dlg-buttons">  
                <div class="ftitle">请输入基元项目的内容</div>  
                    <form id="fm" method="post" novalidate>  
                        <div class="fitem">  
                            <label>基元项目名称：</label><br />  
                            <!--input name="jyxmName" class="easyui-validatebox" required="true"-->
                            <textarea name="jyxmName" class="easyui-validatebox" required="true"></textarea>    
                        </div>  
                        <div class="fitem">  
                            <label>对应的专业：</label><br />  
                            <input name="jyxmProf" class="easyui-combobox" required="true"  editable="false" 
                             data-options="url:'/template_faa/handler/combobox.ashx?name=jcyZY', valueField:'jcyzyId', 
                                           textField:'jcyzyName', panelHeight:'auto'">  
                        </div>  

                    </form>  
                </div>  
                <div id="dlg-buttons">  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" 
                        onclick="saveItem()">保存</a>  
                    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" 
                        onclick="javascript:$('#dlg').dialog('close')">取消</a>  
                </div>
                <script type="text/javascript">  
                    var url;  
                    function newItem(){  
                        $('#dlg').dialog('open').dialog('setTitle','新增基元项目');  
                        $('#fm').form('clear');
                        url = '/template_faa/handler/ajax.ashx?view=jiyuanxm&action=insert';  
                    }
                    function editItem() {
                        var row = $('#dg').datagrid('getSelected');
                        if (row){  
                            $('#dlg').dialog('open').dialog('setTitle','编辑基元项目');
                            $('#fm').form('load', row);
                            url = '/template_faa/handler/ajax.ashx?view=jiyuanxm&action=update&id=' + row.jyxmId;  
                        }
                    }
                    function saveItem() {
                        $('#fm').form('submit', {
                            url: url,
                            onSubmit: function() {
                                return $(this).form('validate');
                            },
                            success: function(result) {
                                var result = eval('(' + result + ')');
                                if (result.errorMsg) {
                                    $.messager.show({
                                        title: 'Error',
                                        msg: result.errorMsg
                                    });
                                } else {
                                    $('#dlg').dialog('close');      // close the dialog
                                    $('#dg').datagrid('reload');    // reload the user data 
                                    $.messager.alert('提示', '保存成功', 'info');
                                }
                            }
                        });  
                    }  
                    function delItem() {
                        var row = $('#dg').datagrid('getSelected');
                        if (row) {
                            $.messager.confirm('提示', '您确认要删除这条基元项目吗？', function(r) {
                                if (r) {
                                    $.post('/template_faa/handler/ajax.ashx?view=jiyuanxm&action=delete', { id: row.jyxmId }, function(result) {
                                        if (result.errorMsg) {
                                            $.messager.show({   // show error message  
                                                title: 'Error',
                                                msg: result.errorMsg
                                            });
                                        } else {                                            
                                            $('#dg').datagrid('reload');    // reload the user data  
                                        }
                                    }, 'json');
                                }
                            });
                        }
                    }
                    function viewItem() {
                        var row = $('#dg').datagrid('getSelected');
                        if (row) {
                            var dest = 'jiyuannr.aspx?project=' + row.jyxmId;
                            location.href = dest;
                        }

                    }                    
                </script>  
            </div>
        </div>
    </div>
    
</asp:Content>
